<?php

namespace App\V3\V3_2_7\Controllers;

use App\Http\Controllers\Controller;
use App\Http\Requests\V3_2_7\AlbumImgTitleRequest;
use App\V3\V3_2_7\Services\AlbumImgTitleService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;

class AlbumImgTitleController extends BaseController
{
    /**
     *编辑画册图片标题
     * Author: zlf
     * Created at 2024/10/8 15:37
     * @param AlbumImgTitleRequest $request
     * @return JsonResponse|null
     */
    public function edit(AlbumImgTitleRequest $request): ?JsonResponse
    {
        $time = time();
        $data = $request->all();
        $data['user_id'] = $this->getUserId();
        $data['main_id'] = $this->getMainUserId();
        $this->operateLog('编辑画册图片标题', $data, $time);
        return Cache::lock(__CLASS__ . __FUNCTION__ . $data['user_id'], 5)
            ->get(function () use ($data, $time) {
                return AlbumImgTitleService::edit($data, $time);
            });
    }
}
